<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title th:text="${comInfo.companyName}+管理员"></title>
    <!-- Bootstrap core CSS -->
    <link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="container">

    <div id="leftNav" class="row row-offcanvas row-offcanvas-right">
        <div class="container" style="margin-bottom: 20px">
            <h2 th:text="${comInfo.companyName}" id="comNameH"></h2>
            <img src="../images/company_welcome_pic.jpg" style="width: 1140px">
        </div>

        <div class="container">
            <form method="post" action="/com_sys_update_after_1">
                <input hidden="hidden" name="companyId" th:value="${comInfo.companyId}">
                <h3 id="lianXiFangShi">联系方式</h3>
                <span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>&nbsp;&nbsp;<h5 style="display: inline-block">联系电话:</h5><input type="text" name="phoneNumber" style="display: inline-block" th:value="${comInfo.phoneNumber}"><br>
                <span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span>&nbsp;&nbsp;<h5 style="display: inline-block">公司所在地:</h5>
                <select style="border-radius: 4px; border: 1px solid #b6bec5" name="addressProvince" id="province">
                    <option th:text="${comInfo.addressProvince}">请选择</option>
                </select>
                <select style="border-radius: 4px; border: 1px solid #b6bec5" name="addressCity" id="city">
                    <option th:text="${comInfo.addressCity}">请选择</option>
                </select><br>
                <span class="glyphicon glyphicon-tag" aria-hidden="true"></span>&nbsp;&nbsp;<h5 style="display: inline-block">详细地址:</h5><input type="text" name="addressReal" style="display: inline-block; width: 400px;" th:value="${comInfo.addressReal}"><br>
                <button class="btn btn-primary" type="submit">保存</button>
            </form>
                <hr style="color: #80d0ff">

            <form method="post" action="/com_sys_update_after_2">
                <h3 id="GongSiJianJie">公司简介</h3>
                <input hidden="hidden" name="companyId" th:value="${comInfo.companyId}">
                <p>
                    <textarea style="display: inline-block; width: 1140px ;height: 155px;" name="introduction" th:text="${comInfo.introduction}"></textarea>
                </p>
                <button class="btn btn-primary" type="submit">保存</button>
            </form>
                <hr style="color: #80d0ff">

            <h3 style="display: inline-block" id="wuLiuZhuanXian">物流专线</h3><small>请点击线路链接修改专线信息</small>
            <p>
                <a target="_blank" th:href="@{'/route_tianjia?companyId='+${comInfo.companyId}}"><button class="btn btn-primary" type="button">添加专线</button></a>
            </p>
            <div th:each="route:${routeInfo}">
                <input name="routeId" th:value="${route.routeId}" hidden="hidden">
                <p>
                    <div class="row">
                        <div class="col-md-4">
                            <a style="text-decoration: none;" target="_blank" th:href="@{'/route_xiugai?routeId='+${route.routeId}}"
                               th:text="${route.routeResourceProvince}+${route.routeResourceCity}+${route.routeResourceCountry}+'→'+
                            ${route.routeDestinationProvince}+${route.routeDestinationCity}+${route.routeDestinationCountry}"></a>
                        </div>
                        <div class="col-md-3">
                            <a style="text-align: left" th:href="@{'/route_shanchu?routeId='+${route.routeId}+'&companyId='+${comInfo.companyId}+'#wuLiuZhuanXian'}"><button class="btn btn-danger btn-sm">删除</button></a>
                        </div>
                    </div>
                    <hr>
                </p>
            </div>

            <hr>

            <h3 id="huoYuanXinXi">货源信息</h3>
            <p>
                <a target="_blank" th:href="@{'/material_tianjia?companyId='+${comInfo.companyId}}"><button class="btn btn-primary">添加货源</button></a>
            </p>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>货源名称</th>
                        <th>出发地→到达地</th>
                        <th>适用车</th>
                        <th>查看</th>
                        <th>删除</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="material:${materialInfo}">
                        <input hidden="hidden" name="materialId" th:value="${material.materialId}">
                        <th th:text="${material.materialName}"></th>
                        <th th:text="${material.resourceAreaProvince}+${material.resourceAreaCity}+${material.resourceAreaCountry}+'→'+${material.destinationAreaProvince}+${material.destinationAreaCity}+${material.destinationAreaCountry}"></th>
                        <th th:text="${material.suitCarLength}+${material.suitableCar}"></th>
                        <th><a style="text-decoration: none" th:href="@{'/material_xiugai?materialId='+${material.materialId}+'#huoYuanXinXi'}" target="_blank"><button type="button" class="btn btn-info btn-sm">查看</button></a></th>
                        <th><a style="text-decoration: none" th:href="@{'/material_shanchu?materialId='+${material.materialId}+'&companyId='+${comInfo.companyId}+'#huoYuanXinXi'}"><button type="button" class="btn btn-danger btn-sm">删除</button></a></th>
                    </tr>
                </tbody>
            </table>

            <hr>

            <h3 id="dingdan">订单信息</h3>
            <span>点击<span style="color: #80d0ff">“接单”</span>按钮即可将订单状态转为<span style="color: #fa5000">“已接单”</span>,此操作不可逆！谨慎操作！</span>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>订单号</th>
                        <th>出发地→到达地</th>
                        <th>发货人</th>
                        <th>发货人手机</th>
                        <th>收货人</th>
                        <th>收货人手机</th>
                        <th>订单状态</th>
                        <th>查看</th>
                        <th>接单</th>
                        <th>拒绝订单</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="order:${orderInfo}">
                        <th id="orderIdTh" th:text="${order.orderId}"></th>
                        <th th:text="${order.orderResProvince}+${order.orderResCity}+${order.orderResCountry}+'→'+${order.orderDesProvince}+${order.orderDesCity}+${order.orderDesCountry}"></th>
                        <th th:text="${order.orderSendPerson}"></th>
                        <th th:text="${order.orderSendPersonPhone}"></th>
                        <th th:text="${order.orderReceivePerson}"></th>
                        <th th:text="${order.orderReceivePersonPhone}"></th>
                        <th th:text="${order.orderStatus}"></th>
                        <th><a id="myModal" data-toggle="modal" data-target="#exampleModal" th:onclick="'javascript:Values(\''+${order.orderId}+'\')'"><button type="button" class="btn btn-info btn-sm">查看</button></a></th>
                        <th><a th:if="${order.orderStatus} eq '未接单'" th:href="@{'/order_status_done?orderId='+${order.orderId}+'&companyId='+${comInfo.companyId}+'#dingdan'}"><button type="button" class="btn btn-warning btn-sm">接单</button></a></th>
                        <!--<th><a th:href="@{'/order_shanchu?orderId='+${order.orderId}+'&companyId='+${comInfo.companyId}+'#dingdan'}"><button type="button" class="btn btn-danger btn-sm">拒绝订单</button></a></th>-->
                        <th><a th:if="${order.orderStatus} eq '未接单'" th:onclick="'javascript:Order_shanchu(\''+${order.orderId}+'\',\''+${comInfo.companyId}+'\')'"><button type="button" class="btn btn-danger btn-sm">拒绝订单</button></a></th>
                    </tr>
                </tbody>
            </table>

            <!------模态框------>
            <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">订单详细信息</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">×</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <p>
                                <span>订单号:</span>
                                <input readonly id="orderId" name="orderId" value="">
                                <span>订单状态:</span>
                                <input readonly id="orderStatus" name="orderStatus" value="">
                            </p>
                            <p>
                                <span>订单状态原因:</span>
                                <input readonly style="width: 450px" id="orderReason" name="orderReason" value="">
                            </p>
                            <hr>
                            <p>
                                <input hidden="hidden" id="orderClient" name="ordeClient" value="">
                                <span>下单人:</span>
                                <input readonly id="orderClientName" value="">
                                <span>联系电话:</span>
                                <input readonly id="orderClientPhone" value="">
                            </p>
                            <hr>
                            <p>
                                <span>货物名称:</span>
                                <input style="width: 150px" readonly id="orderGoodsName" name="orderGoodsName" value="">
                                <span>总件数:</span>
                                <input style="width: 150px" readonly id="orderGoodsNum" name="orderGoodsNum" value="">
                            </p>
                            <p>
                                <span>预估体积:</span>
                                <input style="width: 150px" readonly id="orderGoodsCapacity" name="orderGoodsCapacity" value="">
                                <span>预估重量:</span>
                                <input style="width: 150px" readonly id="orderGoodsWeight" name="orderGoodsWeight" value="">
                            </p>
                            <p>
                                <span>订单备注:</span>
                                <input style=" width: 450px" readonly id="orderRemarks" name="orderRemarks" value="">
                            </p>
                            <hr>
                            <p>
                                <span>出发地:</span>
                                <input style="width: 150px" readonly id="orderResProvince" name="orderResProvince" value="">
                                <input style="width: 150px" readonly id="orderResCity" name="orderResCity" value="">
                                <input style="width: 150px" readonly id="orderResCountry" name="orderResCountry" value="">
                            </p>
                            <p>
                                <span>出发地详细地址:</span>
                                <input style="width: 300px" readonly id="orderResAddress" name="orderResAddress" value="">
                            </p>
                            <p>
                                <span>出发地联系人:</span>
                                <input style="width: 80px" readonly id="orderSendPerson" name="orderSendPerson" value="">
                                <span>手机:</span>
                                <input style="width: 100px" readonly id="orderSendPersonPhone" name="orderSendPersonPhone" value="">
                            </p>
                            <hr>
                            <p>
                                <span>到达地:</span>
                                <input style="width: 150px" readonly id="orderDesProvince" name="orderDesProvince" value="">
                                <input style="width: 150px" readonly id="orderDesCity" name="orderDesCity" value="">
                                <input style="width: 150px" readonly id="orderDesCountry" name="orderDesCountry" value="">
                            </p>
                            <p>
                                <span>到达地详细地址:</span>
                                <input style="width: 300px" readonly id="orderDesAddress" name="orderDesAddress" value="">
                            </p>
                            <p>
                                <span>到达地联系人:</span>
                                <input style="width: 80px" readonly id="orderReceivePerson" name="orderReceivePerson" value="">
                                <span>手机:</span>
                                <input style="width: 100px" readonly id="orderReceivePersonPhone" name="orderReceivePersonPhone" value="">
                            </p>
                            <!--<span>请输入评价内容：</span>-->
                            <!--<textarea class="form-control" aria-label="With textarea" name="evaluateContent"></textarea>-->
                            <div class="modal-footer">
                                <!--<a id="saveA" onclick="saveFcn();"><button type="button" class="btn btn-primary" >保存</button></a>-->
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!------------------>
        </div>

    </div><!--/row-->
    <div id="rightNav" style="top: 200px;display: block;font-size: 14px;width: 100px;text-align: center;position: fixed;">
        <ul style="list-style: none; padding: unset; margin: unset;">
            <li style="background-color: #f3f3f3">&nbsp;</li>
            <li id="Li1" style="background-color: #f3f3f3"><a href="#lianXiFangShi" style="text-decoration: none">联系方式</a></li>
            <li id="Li2" style="background-color: #f3f3f3"><a href="#GongSiJianJie" style="text-decoration: none">公司简介</a></li>
            <li id="Li3" style="background-color: #f3f3f3"><a href="#wuLiuZhuanXian" style="text-decoration: none">物流专线</a></li>
            <li id="Li4" style="background-color: #f3f3f3"><a href="#huoYuanXinXi" style="text-decoration: none">货源信息</a></li>
            <li id="Li5" style="background-color: #f3f3f3"><a href="#dingdan" style="text-decoration: none">订单信息</a></li>
            <li id="Li6" style="background-color: #f3f3f3">&nbsp;</li>
        </ul>
    </div>

    <hr>

    <footer>
        <p>&copy; Company 2018</p>
    </footer>

</div><!--/.container-->


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../jquery-3.3.1.js"></script>
<script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

<script>
    var leftNav = document.getElementById("leftNav");
    var rightNav = document.getElementById("rightNav");
    rightNav.style.left = document.body.clientWidth-leftNav.offsetLeft+'px';
</script>
<script type="text/javascript">
    $("#exampleModal").modal("hide");

    function Order_shanchu(orderId, companyId) {
        var theResponse = window.prompt("请输入拒绝接单原因:", "该订单不满足公司运输需求,请谅解!");
        if(theResponse !== null && theResponse !== ""){
            $.ajax({
                url: "/order_jujue",
                data: {"orderId" : orderId ,
                    "companyId" : companyId,
                    "theResponse" : theResponse},
                success: function (data) {
                    alert("已拒绝该客户订单!");
                    window.location.reload();
                }
            })
        }

    }

    function Values(orderId) {
        $.ajax({
            url: "/getOrderById", 
            data: {"orderId": orderId},
            success: function (data) {
                $("#orderStatus").val(data.data.orderStatus);
                $("#orderReason").val(data.data.orderReason);
                $("#orderResProvince").val(data.data.orderResProvince);
                $("#orderResCity").val(data.data.orderResCity);
                $("#orderResCountry").val(data.data.orderResCountry);
                $("#orderResAddress").val(data.data.orderResAddress);
                $("#orderDesProvince").val(data.data.orderDesProvince);
                $("#orderDesCity").val(data.data.orderDesCity);
                $("#orderDesCountry").val(data.data.orderDesCountry);
                $("#orderDesAddress").val(data.data.orderDesAddress);
                $("#orderSendPerson").val(data.data.orderSendPerson);
                $("#orderSendPersonPhone").val(data.data.orderSendPersonPhone);
                $("#orderReceivePerson").val(data.data.orderReceivePerson);
                $("#orderReceivePersonPhone").val(data.data.orderReceivePersonPhone);
                $("#orderGoodsName").val(data.data.orderGoodsName);
                $("#orderGoodsNum").val(data.data.orderGoodsNum);
                $("#orderGoodsCapacity").val(data.data.orderGoodsCapacity);
                $("#orderGoodsWeight").val(data.data.orderGoodsWeight);
                $("#orderRemarks").val(data.data.orderRemarks);
                $("#orderClient").val(data.data.orderClient);
            }
        });
        $.ajax({
           url: "getClientInfoByOrderId",
           data: {"orderId": orderId},
           success: function (data) {
               $("#orderClientName").val(data.data.clientName);
               $("#orderClientPhone").val(data.data.clientPhone);
           }
        });
        $("#orderId").val(orderId);
    }
</script>

<script>
    $(function () {
        ProvinceBind();

        $("#province").change(function () {
            CityBind();
        })
    });
    function ProvinceBind() {
        // $("#province").html("");
        var str = "<option> 请选择省 </option>";
        $.ajax({
            url: "/getProvince",
            success: function (data) {
                $.each(data.data, function (i,item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#province").append(str);
            },
            error: function () {
                alert("Error省");
            }
        })
    }

    function CityBind() {
        $("#city").html("");
        var options = $("#province option:selected");
        var province = options.val();//province为选中省份的cityName
        // alert(province);
        if (province == "")
            return ;
        $("#city").html("");
        var str="<option> 请选择市 </option>";

        $.ajax({
            url: "/getCities",
            data: {"parentCity": province},
            success: function (data) {
                $.each(data.data, function (i, item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#city").append(str);
            },
            error: function () {
                alert("Error市");
            }
        });
    }
</script>

<script>
    //出发地
    $(function () {
        ProvinceBind1();

        $("#province1").change(function () {
            CityBind1();
        })

        $("#city1").change(function () {
            CountryBind1();
        })
    })
    function ProvinceBind1() {
        // $("#province1").html("");
        var str = "<option> 请选择省 </option>";
        $.ajax({
            url: "/getProvince",
            success: function (data) {
                $.each(data.data, function (i,item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                })
                $("#province1").append(str);
            },
            error: function () {
                alert("Error省");
            }
        })
    }

    function CityBind1() {
        $("#city1").html("");
        var options = $("#province1 option:selected");
        var province = options.val();//province为选中省份的cityName
        // alert(province);
        if (province == "")
            return ;
        $("#city1").html("");
        var str="<option> 请选择市 </option>";

        $.ajax({
            url: "/getCities",
            data: {"parentCity": province},
            success: function (data) {
                $.each(data.data, function (i, item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#city1").append(str);
            },
            error: function () {
                alert("Error市");
            }
        });
    }

    function CountryBind1() {
        $("#country1").html("");
        var options = $("#city1 option:selected");
        var city = options.val();
        if (city == "")
            return;
        $("#country1").html();
        var str="<option> 请选择县 </option>";

        $.ajax({
            url: "/getCountries",
            data: {"parentCity": city},
            success: function (data) {
                $.each(data.data, function (i, item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#country1").append(str);
            }
        });
    }

    //到达地
    $(function () {
        ProvinceBind2();

        $("#province2").change(function () {
            CityBind2();
        })

        $("#city2").change(function () {
            CountryBind2();
        })
    })
    function ProvinceBind2() {
        // $("#province1").html("");
        var str = "<option> 请选择省 </option>";
        $.ajax({
            url: "/getProvince",
            success: function (data) {
                $.each(data.data, function (i,item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                })
                $("#province2").append(str);
            },
            error: function () {
                alert("Error省");
            }
        })
    }

    function CityBind2() {
        $("#city2").html("");
        var options = $("#province2 option:selected");
        var province = options.val();//province为选中省份的cityName
        // alert(province);
        if (province == "")
            return ;
        $("#city2").html("");
        var str="<option> 请选择市 </option>";

        $.ajax({
            url: "/getCities",
            data: {"parentCity": province},
            success: function (data) {
                $.each(data.data, function (i, item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#city2").append(str);
            },
            error: function () {
                alert("Error市");
            }
        });
    }

    function CountryBind2() {
        $("#country2").html("");
        var options = $("#city2 option:selected");
        var city = options.val();
        if (city == "")
            return;
        $("#country2").html();
        var str="<option> 请选择县 </option>";

        $.ajax({
            url: "/getCountries",
            data: {"parentCity": city},
            success: function (data) {
                $.each(data.data, function (i, item) {
                    str += "<option value=" + item.cityName + ">" + item.cityName + "</option>";
                });
                $("#country2").append(str);
            }
        });
    }
</script>

</body>
</html>
